package com.tedu.user.controller;

import com.tedu.common.response.JsonResult;
import com.tedu.user.pojo.dto.UserParam;
import com.tedu.user.pojo.dto.UserQuery;
import com.tedu.user.pojo.vo.UserVO;
import com.tedu.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/user")
public class UserController {
    @Autowired
    UserService userService;
    @GetMapping("/select")
    public JsonResult selectUser(UserQuery userQuery){
        log.debug("查询用户业务,参数:{}",userQuery);
        List<UserVO> list = userService.selectUser(userQuery);
        return JsonResult.ok(list);
    }
    @PostMapping("/save")
    public JsonResult saveUser(UserParam userParam){
        log.debug("保存用户,参数:{}",userParam);
        userService.saveUser(userParam);
        return JsonResult.ok();
    }
    @PostMapping("/delete/{userId}")
    public JsonResult deleteUser(@PathVariable Integer userId){
        log.debug("删除用户,参数:{}",userId);
        userService.deleteUser(userId);
        return JsonResult.ok();
    }

}
